package visual;

import org.apache.commons.math.stat.StatUtils;

public class KMLBarChart {
	
	public String printBarChart(double [] prob, String axis){
    	
		String chartdata = "";
    	for(int i=0;i<prob.length;i++)
    		chartdata += prob[i]+",";
    	//delete last comma
    	chartdata = chartdata.substring(0, chartdata.length()-1);
    	
    	//maximum chart data value
    	//int max = (int)Math.ceil(StatUtils.mean(prob));
    	int max = 100;
    	String URL = "http://chart.apis.google.com/chart?"
                      +"cht=bvg&amp;" //type of chart: grouped bar chart
                      +"chs=350x300&amp;"  // chart size <width>x<height>
                      +"chd=t:"+chartdata+"&amp;" // chart data, different format for different type of data
                      +"chxr=1,0,"+max+"&amp;" // chart axis range axis(0-->x, 1-->y),minimum,maximum
                      +"chds=0,"+max+"&amp;"  //Chart Data Scale: unless you want to do some special scaling (eg. compare percentages of the values instead of showing the actual value) you will scale according to your range. Whatever you have set the min/max of your range (chxr) will be the min/max of your scale (chds).
                      +"chco=ff0000&amp;"  //chart colour: vertical bar '|' to separate the three hex colours in order to get different coloured bars. If I had used a comma ',' then all the bars will be red (the first colour).
                      +"chbh=20,0,20&amp;" // Chart Bar Size : width of the bar(mandatory),spacing between bars in a group(optional),spacing between groups(optional)
                      +"chxt=x,y&amp;" // Chart Axis Type (here, 2 x to name x-axes)
                      +"chxl="+axis+"&amp;" // Chart Axis Label  number axis:name ||to center
                      +"chxs=2,000000,12&amp;" // Chart Axis Style xis #2 to be black with font size of 12
                      +"chts=000000,20&amp;" // Chart Title Style: font color and size
                      +"chg=0,25,5,5"; // Chart Grid lines: chg=<verticalGridLines>,<horizontalGridLines>,<lineSize>,<gapSize>";
        
        
        return URL;
		
	}

}
